
replace seller = "SCHULER" if regexm(seller,"SCHULER")==1 & regexm(seller,"HOME")==1
replace seller = "DEL WEBB" if regexm(seller,"WEBB")==1 & regexm(seller,"DEL")==1
replace seller = "DOVERCP" if regexm(seller,"DOVER")==1 & regexm(seller,"INVESTMENT")==1
replace seller = "M/I" if substr(seller,1,5)=="M & I" | substr(seller,1,5)=="M I &" | substr(seller,1,3)=="M&I" | substr(seller,1,3)=="M-I" | substr(seller,1,4)=="MI &"
replace seller = "PULTE HOMES" if seller =="PN II LLC" | seller=="PN II INC" | seller=="PN II LLP" 
replace seller = subinstr(seller," NEVADA","",.)
replace seller = subinstr(seller," UTAH","",.)
replace seller = subinstr(seller," ARIZONA","",.)
replace seller = subinstr(seller," CAROLINAS","",.)
replace seller = subinstr(seller," INDIANA","",.)
replace seller = subinstr(seller," IDAHO","",.)
replace seller = subinstr(seller," OF","",.)
replace seller = subinstr(seller," HOMES","",.) if seller!="KEYSTONEHOMES" & seller!="LEGENDHOMES" & seller!="HIGHLANDHOMES"
replace seller = subinstr(seller," HOME","",.) if seller!="LEGENDHOMECORP" & seller!="HIGHLANDHOMES"
replace seller = subinstr(seller," HMS","",.) 
replace seller = subinstr(seller," CONSTRUCTION","",.)
replace seller = subinstr(seller," CONST ","",.)
replace seller = subinstr(seller," CORPORATION","",.)
replace seller = subinstr(seller," CORP","",.) if seller!="LEGENDHOMECORP"
replace seller = subinstr(seller," COMPANY","",.) 
replace seller = subinstr(seller," CO ","",.) 
replace seller = subinstr(seller," HOLDINGS","",.)  if substr(seller,1,16)!="HIGHLANDHOLDINGS"  
replace seller = subinstr(seller," HLDGS","",.) if substr(seller,1,11)!="HIGHLANDHLD"
replace seller = subinstr(seller," FAMILY TRUST","",.)
replace seller = subinstr(seller," TRUST","",.)
replace seller = subinstr(seller," DEVELOPMENT GROUP","",.)
replace seller = subinstr(seller," DEVELOPMENT","",.)
replace seller = subinstr(seller," DEV GROUP","",.)
replace seller = subinstr(seller," DEV ","",.)
replace seller = subinstr(seller," INVESTMENT GROUP","",.)
replace seller = subinstr(seller," GROUP","",.) if seller!="KEYSTONEGROUP"
replace seller = subinstr(seller," INVESTMENTS","",.)
replace seller = subinstr(seller," PROPERTIES","",.) 
replace seller = subinstr(seller," VENTURES","",.)  
replace seller = subinstr(seller," ASSOCIATES","",.)
replace seller = subinstr(seller," LLLP","",.)
replace seller = subinstr(seller," LLP","",.)
replace seller = subinstr(seller," LTD","",.) if seller!="MAIN STREET LTD"  
replace seller = subinstr(seller," LLC","",.)
replace seller = subinstr(seller," LLP","",.)
replace seller = subinstr(seller," LP","",.)
replace seller = subinstr(seller," LLC","",.)
replace seller = subinstr(seller," USA","",.)
replace seller = subinstr(seller," INC","",.)
replace seller = subinstr(seller," TEXAS","",.)
replace seller = subinstr(seller," NEVADA","",.)
replace seller = subinstr(seller," CALIFORNIA","",.)
replace seller = subinstr(seller," FLORIDA","",.)
replace seller = subinstr(seller," CUSTOM","",.)
replace seller = subinstr(seller," II","",.)
replace seller = subinstr(seller," I ","",.)
replace seller = subinstr(seller,"'","",.)
replace seller = subinstr(seller," -CL B","",.)
replace seller = subinstr(seller," -CL A","",.)

replace seller = subinstr(seller," INVESTMENT","",.)
replace seller = "PULTE" if seller=="PNII"
replace seller = "TAYLOR MORRISON" if substr(seller,1,3)=="TM "

* subsequently, get rid of gaps in names
replace seller = subinstr(seller," ","",.) if substr(seller,1,3)!="TH "   

* manual adjustments to the names of public firms
if "`1'"==""  {
	replace seller = "CALATLANTIC" if seller=="COLONY HOMES" & year >= 2002
	replace seller = "KB" if seller=="COLONY HOMES LLC" | seller=="COLONY HOMES, LLC" & year>=2003
	replace seller="BROOKFIELDRESIDENTIAL" if substr(seller,1,9)=="BROOKFIEL" & regexm(seller,"RESIDENT")==1
	replace seller="BROOKFIELASSETMANAGEMENT" if substr(seller,1,9)=="BROOKFIEL" & regexm(seller,"ASSET")==1 | substr(seller,1,9)=="BROOKFIEL" & regexm(seller,"ASST")==1
	replace seller="BEAZER" if substr(seller,1,6)=="BEAZER"
	replace seller="BEAZER" if substr(seller,1,6)=="BEAZAR"
	replace seller="RYLAND" if substr(seller,1,7)=="RYLANDG" | substr(seller,1,9)=="THERYLAND" | substr(seller,1,7)=="RYLANDH"   
	replace seller="CALPROP" if seller=="CALPROPCO"
	replace seller="CENTEX" if substr(seller,1,6)=="CENTEX" & year<2010
	replace seller="PULTE" if substr(seller,1,6)=="CENTEX" & year>=2010  /* pulte acquired centex in 2009 */
	replace seller="PULTE" if substr(seller,1,7)=="DELWEBB" & year>=2001  // pulte purchased in 2001
	replace seller="DELWEBB" if substr(seller,1,7)=="DELWEBB" & year<2001  
	replace seller="PULTE" if substr(seller,1,7)=="DIVOSTA"  // pulte purchased in 1998
	replace seller="PULTE" if substr(seller,1,11)=="JOHNWIELAND" & year>=2016 // builder mag classifies them as separate. acquisition occurred in 2016
	replace seller="JOHNWIELAND" if substr(seller,1,11)=="JOHNWIELAND" & year<2016
	replace seller="CENTURYCOMMUNITIES" if substr(seller,1,18)=="CENTURYCOMMUNITIES"
	replace seller="COMSTOCK" if substr(seller,1,8)=="COMSTOCK"
	replace seller="DRHORTON" if substr(seller,1,8)=="DRHORTON"
	replace seller="DOMINION" if substr(seller,1,8)=="DOMINION	"
	replace seller="HOVNANIAN" if substr(seller,1,9)=="HOVNANIAN"
	replace seller="KB" if substr(seller,1,2)=="KB"
	replace seller="LENNAR" if substr(seller,1,6)=="LENNAR"
	replace seller="LGI" if substr(seller,1,3)=="LGI"
	replace seller="M/I" if substr(seller,1,3)=="MI&" | substr(seller,1,3)=="M&I" | substr(seller,1,3)=="M-I" 
	replace seller="MDC" if substr(seller,1,3)=="MDC" & substr(seller,1,8)!="MDCUSTOM" &  substr(seller,1,10)!="MDCHADWICK"
	replace seller="MERITAGE" if substr(seller,1,8)=="MERITAGE"
	replace seller="NVR" if substr(seller,1,3)=="NVR"
	replace seller="PULTE" if substr(seller,1,5)=="PULTE"
	replace seller="TOLLBROTHERS" if substr(seller,1,12)=="TOLLBROTHERS" 
	replace seller="TRIPOINTE" if substr(seller,1,8)=="TRIPOINT" 
	replace seller="TRIPOINTE" if substr(seller,1,6)=="PARDEE"  /* pardee is a subsidiary of tripointe */
	replace seller="WCICOMMUNITIES" if substr(seller,1,3)=="WCI"
	cap replace seller="WOODSIDE-REDH" if substr(seller,1,8)=="WOODSIDE" & PROPERTY_STATE=="NV" | substr(seller,1,8)=="WOODSIDE" & PROPERTY_STATE=="UT" ///
		| substr(seller,1,8)=="WOODSIDE" & PROPERTY_STATE=="CA" | substr(seller,1,8)=="WOODSIDE" & PROPERTY_STATE=="AZ"
}
else if "`1'"=="dealscan" {
	replace seller = "CALATLANTIC" if seller=="COLONY HOMES" 
	replace seller = "KB" if seller=="COLONY HOMES LLC" | seller=="COLONY HOMES, LLC" 
	replace seller="BROOKFIELDRESIDENTIAL" if substr(seller,1,9)=="BROOKFIEL" & regexm(seller,"RESIDENT")==1
	replace seller="BROOKFIELASSETMANAGEMENT" if substr(seller,1,9)=="BROOKFIEL" & regexm(seller,"ASSET")==1 | substr(seller,1,9)=="BROOKFIEL" & regexm(seller,"ASST")==1
	replace seller="BEAZER" if substr(seller,1,6)=="BEAZER"
	replace seller="BEAZER" if substr(seller,1,6)=="BEAZAR"
	replace seller="RYLAND" if substr(seller,1,7)=="RYLANDG" | substr(seller,1,9)=="THERYLAND" | substr(seller,1,7)=="RYLANDH"   
	replace seller="CALPROP" if seller=="CALPROPCO"
	replace seller="CENTEX" if substr(seller,1,6)=="CENTEX" 
	replace seller="DELWEBB" if substr(seller,1,7)=="DELWEBB" 
	replace seller="JOHNWIELAND" if substr(seller,1,11)=="JOHNWIELAND" 
	replace seller="CENTURYCOMMUNITIES" if substr(seller,1,18)=="CENTURYCOMMUNITIES"
	replace seller="COMSTOCK" if substr(seller,1,8)=="COMSTOCK"
	replace seller="DRHORTON" if substr(seller,1,8)=="DRHORTON"
	replace seller="DOMINION" if substr(seller,1,8)=="DOMINION	"
	replace seller="HOVNANIAN" if substr(seller,1,9)=="HOVNANIAN"
	replace seller="KB" if substr(seller,1,2)=="KB"
	replace seller="LENNAR" if substr(seller,1,6)=="LENNAR"
	replace seller="LGI" if substr(seller,1,3)=="LGI"
	replace seller="M/I" if substr(seller,1,3)=="MI&" | substr(seller,1,3)=="M&I" | substr(seller,1,3)=="M-I" 
	replace seller="MDC" if substr(seller,1,3)=="MDC" & substr(seller,1,8)!="MDCUSTOM" &  substr(seller,1,10)!="MDCHADWICK"
	replace seller="MERITAGE" if substr(seller,1,8)=="MERITAGE"
	replace seller="NVR" if substr(seller,1,3)=="NVR"
	replace seller="PULTE" if substr(seller,1,5)=="PULTE"
	replace seller="TOLLBROTHERS" if substr(seller,1,12)=="TOLLBROTHERS" 
	replace seller="TRIPOINTE" if substr(seller,1,8)=="TRIPOINT" 
	replace seller="TRIPOINTE" if substr(seller,1,6)=="PARDEE"  /* pardee is a subsidiary of tripointe */
	replace seller="WCICOMMUNITIES" if substr(seller,1,3)=="WCI"
	cap replace seller="WOODSIDE-REDH" if substr(seller,1,8)=="WOODSIDE" | substr(seller,1,8)=="WOODSIDE" ///
		| substr(seller,1,8)=="WOODSIDE" | substr(seller,1,8)=="WOODSIDE" 
}
